package com.zhu.ssm.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.*;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

@Configuration
//开启事务支持
@EnableTransactionManagement(proxyTargetClass = true)
//@EnableAspectJAutoProxy 开启aop支持，如果有AOP实现的代码
@ComponentScan("com.zhu.ssm") //扫包配置
public class SpringConfig {

    @Bean
    public DataSourceTransactionManager transactionManager(@Autowired DataSource dataSource){
        DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
        return transactionManager;
    }
}
